<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>管理员列表</title>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/jquery-easyui-1.4.1/themes/bootstrap/easyui.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/jquery-easyui-1.4.1/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/jquery-easyui-1.4.1/demo/demo.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-easyui-1.4.1/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-easyui-1.4.1/jquery.easyui.min.js"></script>
</head>
<body>
	 <div class="easyui-panel" title="筛选" style="width:1100px">
        <div style="padding:5px 30px 5px 30px">
        <form id="ff1" method="post">
            <table cellpadding="5">
                <tr>
                	<td>管理员账号:</td><td><input type="text" name="Account" id="Account"/></td><td><input type="button" value="查询" onclick="search()"/></td>
                </tr>
            </table>
        </form>
        </div>
    </div>
    <table id="dg1" title="管理员列表" style="width:1100px;height:370px" class="easyui-datagrid">
    </table>
    <div id="toolbar">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="create()">新建</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="edit()">修改</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroy()">删除</a>
    </div>
    <div id="dlg1" class="easyui-dialog" style="width:500px;height:600px;padding:10px 20px"
            closed="true" buttons="#dlg1-buttons">
        <div class="ftitle">管理员信息</div>
        <form id="fm1" method="post" enctype="multipart/form-data" novalidate>
<!--         	<input type="hidden" name="commodityRemainNumber"> -->
        	<input type="hidden" name="insertTime">
        	<input type="hidden" name="status">
<!--         	<input type="hidden" name="commodityClass"> -->
            <div class="fitem">
                <label>管理员编号:</label>
                <input name="id" class="easyui-textbox" readonly="readonly" >
            </div>
            <div class="fitem">
                <label>管理员账号:</label>
                <input name="administratorAccount" class="easyui-textbox"  required="true">
            </div>
            <div class="fitem">
                <label>管理员类型:</label>
                <input name="administratorType" class="easyui-textbox" required="true">
            </div>
            
        </form>
    </div>
    <div id="dlg1-buttons">
        <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="save()" style="width:90px">Save</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancel</a>
    </div>
    
    <script type="text/javascript">
    $(function () {
	    //加载信息
	    $('#dg1').datagrid({
	    	idField:"id",
	        url: 'administrator_getData.action',
	        loadMsg: '数据装载中......',
	        singleSelect: true,
	        columns: [[
	        { field: 'id', title: '编号', width: 100 },
	        { field: 'administratorAccount', title: '管理员账号', width: 100 },
	        { field: 'administratorType', title: '管理员类型', width: 50 },
	      
	        ]],
	        pagination: true,
	        toolbar:'#toolbar',
	        fitColumns:true,
	        rownumbers: true
	    });
	});
    
    function search(){
    	$("#dg1").datagrid("load", {
            "Account":$("#Account").val()
        });
    }
    
        var url;
        function create(){
            $('#dlg1').dialog('open').dialog('setTitle','新建');
            $('#fm1').form('clear');
 
            url = 'administrator_add.action';
        }
        function edit(){
            var row = $('#dg1').datagrid('getSelected');
            if (row){
                $('#dlg1').dialog('open').dialog('setTitle','修改');
                $('#fm1').form('load',row);
           
                url = 'administrator_edit.action';
            }
        }
        function save(){
            $('#fm1').form('submit',{
                url: url,
                onSubmit: function(){
                    return $(this).form('validate');
                },
                success: function(result){
                    var result = eval('('+result+')');
                    if (result.errorMsg){
                        $.messager.show({
                            title: 'Error',
                            msg: result.errorMsg
                        });
                    } else {
                        $('#dlg1').dialog('close');        // close the dialog
                        $('#dg1').datagrid('reload');    // reload the user data
                    }
                }
            });
        }
        function destroy(){
            var row = $('#dg1').datagrid('getSelected');
            if (row){
                $.messager.confirm('提示','你确定要删除这条记录？',function(r){
                    if (r){
                        $.post('administrator_delete.action',{id:row.id},function(result){
                            if (result.errorMsg){
                            	$.messager.show({    // show error message
                                    title: 'Error',
                                    msg: result.errorMsg
                                });
                            } else {
                            	$('#dg1').datagrid('reload');    // reload the user data
                            }
                        },'json');
                    }
                });
            }
        }
    </script>
    <style type="text/css">
        #fm1{
            margin:0;
            padding:10px 30px;
        }
        .ftitle{
            font-size:14px;
            font-weight:bold;
            padding:5px 0;
            margin-bottom:10px;
            border-bottom:1px solid #ccc;
        }
        .fitem{
            margin-bottom:5px;
        }
        .fitem label{
            display:inline-block;
            width:80px;
        }
        .fitem input{
            width:160px;
        }
    </style>
</body>
</html>